<?php
	header("Content-Type: text/html;charset=utf-8");
	include("../function/_nosql.php"); //
	include("../function/function.php");
	include("../_include.user.judge.php");
	$kboy_userid = $_SESSION['kboy_userid'];
	$aid = chkstr(trim($_REQUEST['aid']));
	$order_no = build_order_no();
	if($kboy_userid){
		// 查询用户信息
			$user_sql = "select * from kboy_user where uid=$kboy_userid";
			$user_rows = mysql_query($user_sql);
			$user_rs = mysql_fetch_array($user_rows);
			$user_realname = $user_rs['user_realname'];
			$user_idcard = $user_rs['user_idcard'];
			$user_phone = $user_rs['user_phone'];
			$user_tel = $user_rs['user_tel'];
			
	}
	   
	 $you = getNewsNums("kboy_order","uid = '$kboy_userid' and aid = '$aid'");
	 if($you == 0){
	     // 查询用户信息
			$user_sql = "select * from kboy_user where uid=$kboy_userid";
			$user_rows = mysql_query($user_sql);
			$user_rs = mysql_fetch_array($user_rows);
			$user_realname = $user_rs['user_realname'];
			$user_idcard = $user_rs['user_idcard'];
			$user_phone = $user_rs['user_phone'];
			$user_tel = $user_rs['user_tel'];
	 }else{
	    $user_sql = "select * from kboy_order where uid='$kboy_userid' and aid='$aid'";
		$user_rows = mysql_query($user_sql);
		$user_rs = mysql_fetch_array($user_rows);
		$user_realname = explode("@@",$user_rs['order_realname']);
		$user_idcard = explode("@@",$user_rs['order_idcard']);
		$user_phone = explode("@@",$user_rs['order_phone']);
		$user_shangche = explode("@@",$user_rs['order_shangche']);
		$order_no = $user_rs['order_no'];
	 }
	?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
    <title>外挂人员</title>
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <link rel="stylesheet" href="css/style.css"/>
    <link rel="stylesheet" type="text/css" href="./css/xiangqing.css"/>
    <script type="text/javascript" src="../js/baidutongji.js"></script>
</head>
<body class="recycle">
	<form action="../ordersave.php?action=<?php if($you == 0){ echo 'orderadd';}else{echo 'ordersave';} ?>" method="post">
		<span class="nav block align">
			<div class="quxiao" onclick="history.go(-1)"><a href="javascript:;"></a>&lt;</div>
			<i class="block">外挂人员信息</i>
		</span>
			<input type="hidden" name="WIDout_trade_no" id="WIDout_trade_no" value="<?=$order_no?>" />
			<input type="hidden" value="<?=$aid?>" name="aid" />
			<input type="hidden" value="1" name="order_isfull" />
			<input type="hidden" name="rWay1" value="1">
			<div class="shanbox"></div>
			<div class="shanbox">
			<?php if($you == 0){ ?>
			<div class="recycleinput"><i>真是姓名</i> <input type="text" name="order_realname[]" value="<?php echo $user_realname; ?>" placeholder="请输入您的真是姓名"/></div>
			<?php if(!empty($user_phone)){ ?>
		    <div class="recycleinput"><i>手机号</i> <input type="text" name="order_phone[]" value="<?php echo $user_phone ?>" placeholder="请输入您的手机号"/></div>
		    <?php }else{ ?>
		    <div class="recycleinput"><i>手机号</i> <input type="text" name="order_phone[]" value="<?php echo $user_tel; ?>" placeholder="请输入您的手机号"/></div>	
		    <?php } ?>	
		    <div class="recycleinput"><i>身份证</i> <input type="text" name="order_idcard[]" value="<?php echo $user_idcard; ?>" placeholder="请输入您的身份证"/></div>
		    <div class="recycleinput"><i>集合地址</i> <input type="text" name="order_shangche[]" value="" placeholder="请输入您的集合地址"/></div>
		    <div class="recycleinput"><i>备注</i> <input type="text" name="order_text" placeholder="特殊事情"/></div>
		    </div>
    		<div class="boxwai">
    		    
    		</div>
    		<?php }else{ ?>
    		    
        		<div class="boxwai">
        			<?php foreach($user_shangche as $k => $v){ ?>
        		    <div class="shanbox">
                		<div class="recycleinput"><i>真是姓名</i> <input type="text" name="order_realname[]" value="<?php echo $user_realname[$k]; ?>" placeholder="请输入您的真是姓名"/></div>
            		    <div class="recycleinput"><i>手机号</i> <input type="text" name="order_phone[]" value="<?php echo $user_phone[$k]; ?>" placeholder="请输入您的手机号"/></div>
            		    <div class="recycleinput"><i>身份证</i> <input type="text" name="order_idcard[]" value="<?php echo $user_idcard[$k]; ?>" placeholder="请输入您的身份证"/></div>
            		    <div class="recycleinput"><i>集合地址</i> <input type="text" name="order_shangche[]" value="<?php echo $v; ?>" placeholder="请输入您的集合地址"/></div>
            		    <?php if($k == 0){ ?>
            		    <div class="recycleinput"><i>备注</i> <input type="text" name="order_text" placeholder="特殊事情"/></div>
            		    <?php } ?>
            		    <div style="height:10px;border-bottom: 1px solid #D7D7D8;"></div>
        		    </div>
        		    <?php } ?>
        		</div>
    		<?php } ?>
    		
	 <!--   <div class="baom">-->
		<!--		<div class="quxiao">-->
		<!--			X-->
		<!--		</div>-->
		<!--</div>-->
		
		<input type="submit" value="确认" style="width: 80%;margin: 20px auto;    border: 1px solid #4b8ee8;height: 30px;background-color: #4b8ee8;color: #fff;border-radius: 10px;display: block;"/>
	</form>
    
    <div class="align change">添加人员信息<a class="tianjia" href="javascript:;">点击此处</a><a class="del" href="javascript:;">删除</a></div>
</body>
</html>
<script src="./js/jquery-1.10.2.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	$(".tianjia").click(function(){
		var str = '<div class="shanbox"><div class="recycleinput" style="margin-top: 20px;border-top: 1px solid #D7D7D8;"><i>真是姓名</i> <input type="text" name="order_realname[]" value="" placeholder="请输入您的真是姓名"/></div> <div class="recycleinput"><i>手机号</i> <input type="text" name="order_phone[]" value="" placeholder="请输入您的手机号"/></div><div class="recycleinput"><i>身份证</i> <input type="text" name="order_idcard[]" value="" placeholder="请输入您的身份证"/></div><div class="recycleinput"><i>集合地址</i> <input type="text" name="order_shangche[]" value="" placeholder="请输入您的集合地址"/></div></div>';
		$(".boxwai").append(str);
	})
		$(".del").on("click",function(){
			var a = $(".shanbox").length-1;
			if(a == 1){
			    alert("个人信息，不能删除")
			}else{
			    $(".shanbox").eq(a).remove();
			}
		})
//	$("input[name=order_shangche]").click(function(){
//		var aid = $("input[name=aid]").val();
////		alert(aid);
//		var from = $(".qing");
//		$.ajax({
//				type:"post",
//				url:"../ajax.php?aid=shang",
//				data:{aid:aid},
//				dataType:"json",
//				success:function(data){
//					
//					if(data["zong"] > 1){
//						$(".baom").css({"height":"240px"});
//						var str = '<div class="qing"><p>请选择上车地</p><form><select name="shangched"><option value="">请选择？</option><option value="'+data["data"][0]+'">'+data["data"][0]+'</option><option value="'+data["data"][1]+'">'+data["data"][1]+'</option></select><br /><input type="button" class="duoshang" value="确定"/></form></div>';
//					}else{
//						if(data['money'] != 0){
//							var str = '<div class="qing"><p>上车地：</p><div class="yige"><a href="javascript:;" class="scddian">'+data["data"]+'</a><a href="javascript:;">确定</a></div></div>';
//						}else{
//							var str = '<div class="qing"><p>集合地点为：</p><div class="yige"><a href="javascript:;" class="scddian">'+data["data"]+'</a><a href="javascript:;">确定</a></div></div>';
//						}
//					}
//					$(".baom").css({"display":"block"});
//					$(".yibu").css({"display":"none"});
//					from.remove();
//					$(".baom").append(str);
//					$(".qing .yige").on('click',function(){
//						var scddian = $(".scddian").html();
//						$("input[name=order_shangche]").val(scddian);
//						$(".baom").hide();
//					})
//					$(".duoshang").on('click',function(){
//						var scddian = $("select[name=shangched]").val();
//						$("input[name=order_shangche]").val(scddian);
//						$(".baom").hide();
//					})
//				}
//			});
//		})
	$(".quxiao").click(function(){
			$(".baom").css({"display":"none"});
		})
</script>